{include file="public/header" /}
</head>
<body>
	<div id="main-container">
		{include file="public/menu" /}
		<div class="main">
			<div class="notice">{$position.url}</div>
			<div class="main_content">
				<div class="title">
					<span>{$position.name}</span>
				</div>
				<form  class="layui-form layui-form-pane" id="formrec" method="post" role="form">
					<div class="layui-form-item">
			            <label class="layui-form-label">栏目名称</label>
			            <div class="layui-input-inline">
			                <input class="layui-input" type="text" name="title" placeholder="栏目名称" lay-verify="required">
			            </div>
			        </div>

			        <div class="layui-form-item">
			            <label class="layui-form-label">副名称</label>
			            <div class="layui-input-inline">
			                <input class="layui-input" type="text" name="subtitle" placeholder="副名称" >
			            </div>
			        </div>
					
					<div class="layui-form-item">
			            <label class="layui-form-label">所属栏目</label>
			            <div class="layui-input-inline w300">
			                <select data-val="true" lay-filter="pid" name="pid"  lay-verify="required">
			                    <option selected="selected" value="0">默认顶级</option>
			                    {volist name="catelist" id="v"}
			                    <option value="{$v.id}">{if $v.pid eq 0}{else}{if $v.lvl eq 2}　├ {else}　　├ {/if}{/if}{$v.title}</option>
			                    {/volist}
			                </select>
			            </div>
			        </div>

					<div class="layui-form-item">
			            <label class="layui-form-label">排序</label>
			            <div class="layui-input-inline">
			                <input name="sort" lay-verify="number" autocomplete="off" value="0" placeholder="输入顺序" class="layui-input w300" type="text">
			            </div>
			        </div>
					
					<div class="layui-form-item">
	                    <label class="layui-form-label">栏目图片</label>
	                    <div class="layui-input-inline">
							<input id="path1" class="layui-input" type="text" name="pic" readonly="true"><br>
							<img id="img_path1" class="defimg" onerror="javascript:this.style.display='none';">
	                    </div>
	                    <div class="layui-input-inline w450">
			            	<input type="button" rel="path1" value="选择站内图片" class="fl BrowerPicture file_btn" />
			            	<div class="site-demo-upload upload-img fl ml5">
				                <div class="site-demo-upbar">
				                    <input type="file" name="file" class="layui-upload-file" id="upload-image">
				                </div>
				        	</div>
			            </div>
	                </div>
					
					<div class="title_bar mb20">
						模板设置
					</div>
					
					<div class="layui-form-item">
			            <label class="layui-form-label">内容模型</label>
			            <div class="layui-input-inline w300">
			                <select data-val="true" lay-filter="mid" name="mid" lay-verify="required">
			                	<option selected="selected" value="">选择模型</option>
			                    {volist name="modellist" id="v"}
			                    <option value="{$v.id}">{$v.title}</option>
			                    {/volist}
			                </select>
			            </div>
			        </div>

			        <div class="layui-form-item">
			            <label class="layui-form-label">封面页模版</label>
			            <div class="layui-input-inline w300">
			                <select data-val="true" lay-filter="tpl_cover" name="tpl_cover" >
			                	<option selected="selected" value="">选择模版</option>
			                    {volist name="coverfile" id="v"}
			                    <option value="{$v}">{$v}</option>
			                    {/volist}
			                </select>
			            </div>
			        </div>

			        <div class="layui-form-item">
			            <label class="layui-form-label">列表页模版</label>
			            <div class="layui-input-inline w300">
			                <select data-val="true" lay-filter="tpl_list" name="tpl_list" >
			                	<option selected="selected" value="">选择模版</option>
			                    {volist name="listfile" id="v"}
			                    <option value="{$v}">{$v}</option>
			                    {/volist}
			                </select>
			            </div>
			        </div>

			        <div class="layui-form-item">
			            <label class="layui-form-label">内容页模版</label>
			            <div class="layui-input-inline w300">
			                <select data-val="true" lay-filter="tpl_show" name="tpl_show">
			                	<option selected="selected" value="">选择模版</option>
			                    {volist name="showfile" id="v"}
			                    <option value="{$v}">{$v}</option>
			                    {/volist}
			                </select>
			            </div>
			        </div>

					<div class="title_bar mb20">
						搜索引擎优化
					</div>

					<div class="layui-form-item">
			            <label class="layui-form-label">SEO标题</label>
			            <div class="layui-input-inline">
			                <input class="layui-input w700" type="text" name="seo_title" placeholder="SEO标题" >
			            </div>
			        </div>

					<div class="layui-form-item">
			            <label class="layui-form-label">SEO关键词</label>
			            <div class="layui-input-inline">
			                <input class="layui-input w700" type="text" name="seo_keywords" placeholder="SEO关键词" >
			            </div>
			        </div>

					<div class="layui-form-item">
			            <label class="layui-form-label">SEO描述</label>
			            <div class="layui-input-inline">
			                <textarea name="seo_desc" placeholder="SEO描述" class="layui-textarea w700"></textarea>
			            </div>
			        </div>

			        <div class="title_bar mb20">
						附加设置
					</div>

					<div class="layui-form-item">
			            <label class="layui-form-label">栏目简介</label>
			            <div class="layui-input-inline">
			                <textarea name="desc" id="desc"></textarea>
			            </div>
			        </div>

			        <div class="layui-form-item">
                        <label class="layui-form-label">栏目内容</label>
                        <div class="layui-input-inline">
                            <textarea name="content" id="content"></textarea>
                        </div>
                    </div>

					<div class="title_bar mb20">
						其他设置
					</div>
					
					<div class="layui-form-item">
	                    <label class="layui-form-label">栏目属性</label>
	                    <div class="layui-input-inline w450">
	                        <input type="radio" name="cover" value="0" title="列表(允许发表文档)" checked>
	                        <input type="radio" name="cover" value="1" title="频道(不允许发表文档)">
	                    </div>
	                </div>

					<div class="layui-form-item">
			            <label class="layui-form-label">外部链接</label>
			            <div class="layui-input-inline">
			                <input class="layui-input" type="text" name="jumpurl" placeholder="外部链接">
			            </div>
			            <font class="font_tip">内部链接可使用“@其他栏目ID”的方式进行内链，外链填写完整URL“http://~~”</font>
			        </div>

			        <div class="layui-form-item">
			            <label class="layui-form-label">栏目别名</label>
			            <div class="layui-input-inline">
			                <input class="layui-input" type="text" name="etitle" placeholder="不填写则自动生成">
			            </div>
			        </div>

			        <div class="layui-form-item">
                        <label class="layui-form-label">地区分站</label>
                        <div class="layui-input-inline">
                            <input type="checkbox" checked="" name="isarea" lay-skin="switch" lay-filter="switchTest">
  
                        </div>
                    </div>

					<div class="layui-form-item">
	                    <label class="layui-form-label">是否显示</label>
	                    <div class="layui-input-inline">
	                        <input type="checkbox" checked="" name="status" lay-skin="switch" lay-filter="switchTest">
	                    </div>
	                </div>

	                <div class="layui-form-item">
	                    <label class="layui-form-label">新窗口打开</label>
	                    <div class="layui-input-inline">
	                        <input type="checkbox" name="target" lay-skin="switch" lay-filter="switchTest">
	                    </div>
	                </div>
					
					<div class="layui-form-item">
	                    <label class="layui-form-label">导航栏显示</label>
	                    <div class="layui-input-inline w450">
	                        <input type="radio" name="nav" value="0" title="不显示" checked>
	                        <input type="radio" name="nav" value="1" title="主导航">
	                        <input type="radio" name="nav" value="2" title="尾导航">
	                        <input type="radio" name="nav" value="3" title="都显示">
	                    </div>
	                </div>

					<div class="layui-form-item">
	                    <label class="layui-form-label"></label>
	                    <div class="layui-input-inline">
			              <button class="btn" lay-submit="" lay-filter="save" data-href='{:url('addcategory')}'>提交</button>
	                    </div>
			        </div>
				
				</form>
			</div>
		</div>
	</div>
<script type="text/javascript">
	var option= {toolbars: [[
            'fullscreen', 'source', '|',
            'bold', 'italic', 'underline', 'strikethrough', 'forecolor', 'backcolor',
            'paragraph', 'fontfamily', 'fontsize', '|',
            'indent', 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|',
            'link', 'unlink',
        ]]};

    window.UEDITOR_HOME_URL = '__UEDITOR__/';
    window.onload = function() {
        window.UEDITOR_CONFIG.initialFrameWidth=700;
        window.UEDITOR_CONFIG.initialFrameHeight=300;
        UE.getEditor('desc',option);
        UE.getEditor('content');

    }
</script>
<script type="text/javascript" src="__UEDITOR__/ueditor.config.js"></script>
<script type="text/javascript" src="__UEDITOR__/ueditor.all.min.js"></script>  

<script>
layui.use(['form','common','upload'], function(){
        var $ = layui.jquery;
        $form = $('form');
        var form = layui.form(),layer = layui.layer, common=layui.common;
        
        //上传图片
        layui.upload({
            url: "{:url('Upload/upload',['file'=>'file'])}" //上传接口
            ,before: function(input){
                //console.log('图片上传中');
            }
            ,title:'上传图片'
            ,elem: '#upload-image' //指定原始元素，默认直接查找class="layui-upload-file"
            ,method: 'post' //上传接口的http类型
            ,ext: 'jpg|png|gif'
            ,type:'images'
            ,success: function(data){ //上传成功后的回调
                if(data.status == 1){
                    $("#path1").val('/uploads/image/'+data.image_name);
                    $("#img_path1").attr('src', '/uploads/image/' + data.image_name).show();
                }else{
                    alert(data.error_info);
                }
            }
        });

        $('.BrowerPicture').click(function(){
        	var path = $(this).attr('rel');
        	layer.open({
			    type: 2,
			    title: '选择站内图片',
			    shadeClose: true,
			    shade: false,
			    anim: 2,
			    area: ['750px', '350px'],
			    content: ['{:url('upload/browsefile', array('stype' => 'picture'))}?docname='+path]
			});
		});

        //监听提交
        form.on('submit(save)', function(data){
            var sub = true;
            var url = $(this).data('href');
            if(url){
                if(sub){
                    $.ajax({
                        url: url,
                        type: 'post',
                        dataType: 'json',
                        data: data.field,
                        success: function (info) {
                            if (info.code == 1) {
                                common.layerAlertSHref(info.msg, '提示', "{:url('category/index')}");
                            }
                            else {
                                common.layerAlertE(info.msg, '提示');
                                $(data.elem).removeAttr("disabled").text("提交");
                            }
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            common.layerAlertE(textStatus, '提示');
                        }
                    });
                }
            }else{
                common.layerAlertE('链接错误！', '提示');
            }
            return false;
        });
    });
</script>
</body>
</html>